#ifndef _DirectIntegrator_H_
#define _DirectIntegrator_H_

#pragma once
#include "Integrator.h"

class DirectTraceState : public TraceState {
public:
	int depth;

	DirectTraceState(int depth = 0) : depth(depth) {}
	~DirectTraceState() {}

	inline bool shouldContinue() const {
		return depth > 0;
	}

	inline DirectTraceState next() const {
		return DirectTraceState(depth - 1);
	}

	inline DirectTraceState current() const {
		return DirectTraceState(depth);
	}
};

class DirectIntegrator : public Integrator {
private:
	int maxDepth;

public:
	DirectIntegrator(int maxDepth) : maxDepth(maxDepth) {}
	~DirectIntegrator() {}

	Color Li(const Scene *scene, const Ray &ray, const TraceState & traceState) const;

	Color Li(const Scene *scene, const Ray &ray) const {
		return Li(scene, ray, DirectTraceState(maxDepth));
	}

	Color getIrradiance(const Scene *scene, const Vector3 &position, const Vector3 & normal, const TraceState & traceState, const Color & diffuseReflectance) const {
		return scene->sampleLight(position, normal) *= diffuseReflectance;
	}
};

#endif // _DirectIntegrator_H_